package apis

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"mini-gde/pkg"
	"mini-gde/service"
	"net/http"
)

func ListPods(c *gin.Context) {
	//namespace := c.Param("namespace")
	//fmt.Print(namespace)
	req := make(map[string]string)
	c.BindJSON(&req)
	apps := req["namespace"]
	fmt.Print(apps)
	pods := service.ListPods(apps)
	c.JSON(http.StatusOK, gin.H{
		"code": pkg.SUCCESS,
		"msg":  pkg.GetMsg(pkg.SUCCESS),
		"data": pods,
	})
}

func DeletePods(c *gin.Context) {
	req := make(map[string]string)
	c.BindJSON(&req)
	apps := req["uid"]
	fmt.Print(apps)
	var err error
	err = service.DeletePod(apps)
	if err != nil {
		c.JSON(http.StatusInternalServerError, gin.H{
			"code": pkg.ERROR,
			"msg":  pkg.GetMsg(pkg.ERROR),
		})

	} else {

		c.JSON(http.StatusOK, gin.H{
			"code": pkg.SUCCESS,
			"msg":  pkg.GetMsg(pkg.SUCCESS),
		})
	}
}
